home *** CD-ROM | disk | FTP | other *** search
- Path: gate.net!pslfl2-23
- From: bhutto@gate.net (William Hutto)
- Newsgroups: comp.lang.c
- Subject: Re: ugly constants and header files
- Date: 5 Jan 1996 02:44:43 GMT
- Organization: CyberGate, Inc.
- Message-ID: <4ci3ar$f84@news.gate.net>
- References: <1996Jan3.155754.111142@kuhub.cc.ukans.edu>
- NNTP-Posting-Host: pslfl2-44.gate.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <1996Jan3.155754.111142@kuhub.cc.ukans.edu>,
- anh@kuhub.cc.ukans.edu wrote:
- >Hello,
- >
- >I have a list of constants, some defined using #define, some are string
- >constants a la char *gSuperStrings[]={"aa","bb"};
- >
- >These constants are used by multiple modules which are linked together to
- >a program. However, I have more than one program using these constants,
- >hence I put the constants in a header file. I know it is ugly to put
- >definitions in a header file.
- >
- >My current solution is to change all the #define to integer constants and
- >to keep 2 files:
- >
- >my_const.h --- To be included only once (perferably by the main()
- > module). Definitions
- >
- >my_ext.h --- To be included by any modules using the constants.
- > Declarations.
- >
- >Is this the best solution? Are there any other way?
- >
- >Thank-you,
- >Anh
-
- Put your #define's in a header file. Put your _const_ variables in a source
- file by themselves if you want. If they're to be truely global, declare them
- _extern_ in a header file.
-
- Bill
-
- "Whatcha got on?...Your mind?"
-